package com.skycode7.servlet;

import com.skycode7.bean.NoticeBean;
import com.skycode7.dao.NoticeDao;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/noticedetail.html")
public class NoticeDetailServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        String NoticeId = req.getParameter("NoticeId");
        int id = Integer.parseInt(NoticeId);
        NoticeBean notice = (new NoticeDao().getOne(id));
        req.setAttribute("title",notice.getNewsTitle());
        req.setAttribute("content",notice.getNewsContent());
        req.getRequestDispatcher("/noticeFrontDetail.jsp").forward(req,resp);
    }
}
